<%@ page import="com.utils.SysConf" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String baseUrl = SysConf.get("weixin.baseUrl");
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="keywords" content="助力">
    <meta name="description" content="助力">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telphone=no, email=no"/>
    <meta name="HandheldFriendly" content="true">
    <title>赞赏助力网</title>
    <link rel="stylesheet" href="${path}/style/weui.min.css"/>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .ui-content {
            position: absolute;
            z-index: -1;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            opacity: 0.8;
        }

        ul, ol, li, dl {
            list-style-type: none;
        }

        body {
            display: block;
            background-color: #fff;
            opacity: 8.2;;
        }

        .team-main {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
        }

        .re-item {
            border: 2px solid #D65945;
            border-radius: 8px;
            width: 25%;
            height: 54px;
            margin-top: 14px;
            margin-left: 16px;
            text-align: center;
            font-size: 1.9em;
            color: #D65945;
            font-style: italic;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding-top: 1%;
        }

        .head1 {
            height: 9.5%;
            background-color: #f7381c;
        }

        .head {
            height: 12.5%;
            background-color: #f7381c;
            border-radius: 0 0 65% 65%/0 0 100% 100%;
        }

        .log {
            width: 20%;
            height: 11%;
            position: absolute;
            border-radius: 50%;
            margin-left: 39%;
            margin-top: -10%;
        }

        .head-text {
            color: white;
            font-weight: bold;
            font-size: 1.2em;
            float: left;
            margin: 7%;
        }

        .ui-text-center {
            text-align: center;
            height: 17%;
        }

        .ui-text-hot {
            margin-top: 12%;
            font-size: 1.8em;
        }

        .ui-text-yc {
            margin: 3px;
            margin-left: 2px;
            font-size: 0.85em;
        }

        .content {
            height: 35%;
        }

        .ui-amt-uint {
            font-size: 0.15em;
        }

        .foot {
            height: 17%;
        }

        .ui-foot-text { 
            text-align: center;
            width: 100%;
            font-size: 0.85em;
            font-family: -webkit-body;
            opacity: 0.9;
           margin-top: 18%;
        }


        .other-amt {
            width: 100%;
            text-align: center;
            color: #0e51de;
            font-weight: 400;
            font-size: 0.85em;
            margin-top: 11%;
        }

        .cell-body {
            font-size: 1.2em;
            background-color: #FAFBFD;
        }

        .weui-input {
            background-color: white;
        }

        .weui-cells__title {
            color: black;
            font-size: 1.2em;
        }

        .font-black {
            color: black;
            font-weight: 400;
        }

        .weui-cells{
            margin-top: 0;
        }

        .weui-cells_form{
            margin-bottom: 5%;
        }

        .close{
            position: absolute;
            width: 0.1em;
            height: 1.0em;
            background: #333;
            -webkit-transform: rotate(45deg);
            -moz-transform: rotate(45deg);
            -o-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
            transform: rotate(45deg);
            display: inline-block;
            left: 11%;
            opacity: 0.6;
        }
        .close:after{
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width:0.1em;
            height:1.0em;
            background: #333;
            -webkit-transform: rotate(270deg);
            -moz-transform: rotate(270deg);
            -o-transform: rotate(270deg);
            -ms-transform: rotate(270deg);
            transform: rotate(270deg);
        }
    </style>
</head>
<body>
<div class="ui-content">
    <div class="head1">
        <p class="head-text"></p>
    </div>
    <div class="head"></div>
    <img src="${path}/images/zl.jpg" class="log">
    <div class="ui-text-center">
        <h2 class="ui-text-hot">热点事件美文</h2>
        <p class="ui-text-yc">原创不易，写作很苦！</p>
    </div>
    <div class="content">
        <div class="team-main">
            <div class="re-item active" data-amt="2">2<span class="ui-amt-uint">元</span></div>
            <div class="re-item" data-amt="5">5<span class="ui-amt-uint">元</span></div>
            <div class="re-item" data-amt="10">10<span class="ui-amt-uint">元</span></div>
            <div class="re-item" data-amt="20">20<span class="ui-amt-uint">元</span></div>
            <div class="re-item" data-amt="30">30<span class="ui-amt-uint">元</span></div>
            <div class="re-item" data-amt="50">50<span class="ui-amt-uint">元</span></div>
        </div>
        <div class="other-amt">其它金额</div>
    </div>
    <div>
        <p class="ui-foot-text">赞赏是为了表示鼓励而对文章内容的无偿赠与</p>
    </div>
</div>


<div class="js_dialog cell-body" id="iosDialog2" style="display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-cells weui-cells_form">

            <div class="weui-cells__title font-black">
                <span class="close"></span>
                <span class="font-black">其它金额</span>
            </div>
            <div class="weui-cell cell-body">
                <div class="weui-cell__hd">
                    <label class="weui-label font-black">金额(元)</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="number" pattern="[0-9]*" placeholder="请填数字" maxlength="5"
                           id="input-other"/>
                </div>
            </div>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">赞赏</a>
            </div>
        </div>
    </div>
</div>

</body>
<script src="${path}/js/jquery.min.js"></script>
<script src="${path}/js/layer/layer.js"></script>
<script src="${path}/js/scanqr.js"></script>

<script>
    var url = window.location.href;
    $('.re-item').on('click', function () {
        var that = $(this);
        var amount = parseFloat(that.attr('data-amt'));
        var lain = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        doPay(amount, function () {
            layer.close(lain);
        });
    });

    function doPay(amount, callback) {
        $.post('<%=baseUrl%>/jianpay/payment.do', {
            amount: amount,
            busiId: url,
        }, function (result) {
            callback();
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', failtip, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', failtip);
                    document.attachEvent('onWeixinJSBridgeReady', failtip);
                }
            } else {
                open = false;
                payByWx(result);
            }
        }, 'json');
    }

    function payByWx(pay_info) {
        WeixinJSBridge.invoke('getBrandWCPayRequest', {
            "appId": pay_info.appId,//公众号名称，由商户传入
            "timeStamp": pay_info.timeStamp,//时间戳，自1970年以来的秒数
            "nonceStr": pay_info.nonceStr,//随机串
            "package": pay_info.package,
            "signType": pay_info.signType,//微信签名方式:
            "paySign": pay_info.paySign//微信签名
        }, function (res) {
            if (res.err_msg == "get_brand_wcpay_request:ok") {
                //使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                layer.msg("支付成功");
                history.back();
            } else {
//                layer.msg("支付失败" +  JSON.stringify(res));
                layer.msg("支付失败");
                history.back();
            }
        });
    }

    function failtip() {
//        layer.alert("显示图片", {icon: 5})
    }

    var $iosDialog2 = $('#iosDialog2');
    $('.other-amt').on('click', function () {
        $iosDialog2.fadeIn(200);
    });

    $('.close').on('click', function () {
        $('#iosDialog2').fadeOut(200);
    });

    $('#showTooltips').on('click', function () {
        var amount = $('#input-other').val();
        $('#iosDialog2').fadeOut(200);
        doPay(amount, function () {

        })
    });
</script>
</html>